package cn.tedu.opencv.ex;

import lombok.Getter;

/**
 * 服务（业务）异常
 *
 * @author xukai
 * @date 20200419
 */
public class ServiceException extends RuntimeException {

    @Getter
    private final ResultCodeEnum resultCode;

    public ServiceException(ResultCodeEnum resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    public ServiceException(ResultCodeEnum resultCode, String message) {
        super(message);
        this.resultCode = resultCode;
    }

    public ServiceException(ResultCodeEnum resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    public ServiceException(ResultCodeEnum resultCode, String message, Throwable cause) {
        super(message, cause);
        this.resultCode = resultCode;
    }

    /**
     * 重写fillInStackTrace 业务异常不需要堆栈信息，提高效率.
     *
     * @see Throwable # fillInStackTrace()
     */
//    @Override
//    public Throwable fillInStackTrace() {
//        return this;
//    }

}
